﻿using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;

namespace Demo.Framework.PostProcessing
{
    class DepthOfField : PostProcessor
    {
        // Depth map and un-blurred render of scene. The blurred render
        // will be set as the Input value
        public Texture2D DepthMap;
        public Texture2D Unblurred;

        public DepthOfField(GraphicsDevice graphicsDevice, ContentManager content)
            : base(content.Load<Effect>("Effects/DepthOfField"), graphicsDevice)
        {
        }

        public override void Draw()
        {
            // Set the two textures above to the second and third
            // texture slots
            GraphicsDevice.Textures[1] = Unblurred;
            GraphicsDevice.Textures[2] = DepthMap;

            // Set the samplers for all three textures to PointClamp
            // so we can sample pixel values directly
            GraphicsDevice.SamplerStates[0] = SamplerState.PointClamp;
            GraphicsDevice.SamplerStates[1] = SamplerState.PointClamp;
            GraphicsDevice.SamplerStates[2] = SamplerState.PointClamp;

            base.Draw();
        }
    }
}
